package sctu.edu.java.year2016.team08.lisonghong.day20160521.chapter4_3;

/**
 * 编写Java程序，使用while循环语句计算1+1/2!+1/3!+...+1/20!之和。
 * Created by 松红 on 2016/5/21.
 */
public class chapter4_3 {
    public static void main(String[] args) {
        int a = 1;
        double sum = 0;
        double c = 1;
        while (a <= 20) {
            c = c * a;
            sum = sum + (1 / c);
            a++;
        }
        System.out.println(sum);
    }
}
